package top.liujiachen.springboot.shiro.controller;

import com.alibaba.druid.stat.DruidStatManagerFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.liujiachen.springboot.shiro.entity.SysUser;
import top.liujiachen.springboot.shiro.mapper.SysUserMapper;

import java.util.List;

@RestController
public class DruidController {

    @Autowired
    private SysUserMapper userMapper;

    @GetMapping("/druid/stat")
    public Object druidStat(){
        // DruidStatManagerFacade#getDataSourceStatDataList 该方法可以获取所有数据源的监控数据，除此之外 DruidStatManagerFacade 还提供了一些其他方法，你可以按需选择使用。
        return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
    }

    @GetMapping("/users")
    public Object testSelect() {
        List<SysUser> userList = userMapper.selectList(null);
        userList.forEach(System.out::println);
        return userList;
    }

}
